import { Loading } from 'element-ui'

var globalMask = null
/**
 * 打开遮罩层
 */
const showLoading = (msg) => {
  globalMask = Loading.service({
    lock: true,
    text: msg || `加载中...`,
    spinner: 'el-icon-loading',
    background: 'rgba(0, 0, 0, 0.5)'
  })
}
/**
 * 关闭遮罩层
 */
const hideLoading = () => {
  if (globalMask) {
    globalMask.close()
  }
}

export default {
  showLoading,
  hideLoading
}
